package thread_learn2;

import java.util.ArrayList;
import java.util.Arrays;

class Func3{
    public int count;
    static ArrayList arrayList=new ArrayList<>();
    public static void add(){
        synchronized(Func3.class){
        }

    }
}
public class demon3 {
    public static void main(String[] args) throws InterruptedException {
        Func func=new Func();
        Thread thread=new Thread(()->{
            for (int i = 0; i < 5000; i++) {
                func.add();
            }
        });
        Thread thread1=new Thread(()->{
            for (int i = 0; i < 5000; i++) {
                func.add();
            }
        });
        thread.start();
        thread1.start();
        thread1.join();
        thread.join();
        System.out.println(func.count);

    }
}

